﻿using EasyService;
using EasyTask.EasyCore;
using EasyTask.EasyHelper;
using log4net;
using System.Threading.Tasks;
using Topshelf;

namespace EasyRunner.EasyCore
{
    class ServiceRunner
    {
        private ILog logger = LogManager.GetLogger(nameof(ServiceRunner));

        TaskService taskService = new TaskService();
        public async Task Start()
        {
            await QuartzManager.AddJobAsync<MonitorJob>(Config.GetValue("EasyTaskMonitorCron"));
        }

        public async Task Stop()
        {
            //手动停止后进行的操作
            await taskService.WhenManualStopExcuteAsync();
            await QuartzManager.ShutdownAllAsync();
        }

        public async Task Continue(HostControl hostControl)
        {
            await QuartzManager.ResumeAllAsync();
        }

        public async Task Pause(HostControl hostControl)
        {
            await QuartzManager.PauseAllAsync();
        }
    }
}
